<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>

		<style>
			.tip {
				height: 40px;
				background-color: #F5F6F7;
				padding: 0px 10px;
				margin-bottom: 10px;
				border-radius: 10px;
				line-height: 40px;
				font-size: 13px;
			}
		</style>
	</head>
	<link rel="stylesheet" type="text/css" href="../mdedit/css/editormd.min.css" />
	<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
	<script src="../mdedit/editormd.js"></script>

	<!--  引入 Layui.css -->
	<link rel="stylesheet" href="../layui/css/layui.css" />
	<script src="../layui/layui.js"></script>

	<body>
		<div class="tip">
			<span style="color: red;">警告：</span>
			没有提交的内容默认保存1天的时间。
			<span style="color: blue;">
				保存快捷键：
			</span>
			CTRL+S。
			<span style="color: #10707F;">如有BUG请及时反馈,QQ:2246483156，答案：是</span>

			<div style="float: right; margin-right: 20px;">
				<button type="button" class="layui-btn layui-btn-primary">插入图片</button>
				<button type="button" class="layui-btn" onclick="openWindow()">确认发布</button>
			</div>
		</div>
		<div id="test-editormd">
			<textarea></textarea>
		</div>
	</body>
	<script type="text/javascript">
		//一般直接写在一个js文件中
		layui.use(['layer', 'form'], function() {
			var layer = layui.layer,
				form = layui.form;
		});
		var testEditor;
		$(function() {
			testEditor = editormd("test-editormd", {
				width: "100%",
				height: 640,
				syncScrolling: "single",
				//这个lib路径和项目里面对应
				path: "../mdedit/lib/",
				saveHTMLToTextarea: true,
				emoji: true
			});
		});


		// 弹出文章发布的窗口
		function keyDown(e) {
			var currKey = 0,
				e = e || event || window.event;
			currKey = e.keyCode || e.which || e.charCode;
			if (currKey == 83 && (e.ctrlKey || e.metaKey)) {

				// 调用弹窗的方法
				openWindow();
				return false;
			}
		}

		function openWindow() {
			//iframe层
			layer.open({
				type: 2,
				title: '发布文章',
				shadeClose: true,
				shade: 0.8,
				area: ['600px', '50%'],
				content: 'ConfirmRelease.html' //iframe的url
			});
		}


		document.onkeydown = keyDown;
	</script>
</html>
